<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="font-awesome/css/font-awesome.css" />
	</head>
	<body>
		 <button onclick="change()" id="color">切换1</button><br />
		 <button onclick="color1()">输出颜色</button><br />
		 <i id="dianzan" onclick="dianzan(this)" num="1" class="fa fa-hand-o-left fa-3x" aria-hidden="true"></i>

		<div  id ="mydiv" style="background-color: hotpink; width: 300px; height: 300px;">
		<div  id ="mydiv2" style="background-color: hotpink; width: 200px; height: 200px;">
		<div  id ="mydiv3" style="background-color: hotpink; width: 100px; height: 100px;"></div>
		</div>
		</div>
		
		<div>
			<div id="text" ></div>
			账号：<input type="text" name="account" id="account" />
			密码：<input type="text" id="password"  />
			<button onclick="denglu()"> 登录</button>
		</div>
		
		<table id="mytable" border="1">
		<thead>
			<tr>
				<th>第一列</th>		
				<th>第二列</th>
				<th>第三列</th>
			</tr>
		</thead>
		<tbody>
		<tr>
			<td>LPY</td>
			<td>1997.07.28</td>
			<td>1234567</td>
		</tr>
		<tr>
			<td>LWH</td>
			<td>07.20</td>
			<td>123567</td>
		</tr>
		<tr>
			<td>sss</td>
			<td>0420</td>
			<td>12567</td>
		</tr>
		</tbody>
		
	</table>

		<script type="text/javascript">
			console.log(num1);
			var num1=0;
			function change(){
				var colors=['balack','grey','red','bule','green']
			if( num1>4){
					var div=document.getElementById("mydiv"); 
					var div2=document.getElementById("mydiv2");
			         var div3=document.getElementById("mydiv3");
			         num1=0;
					 div.style.backgroundColor=colors[num1+1];
				     div2.style.backgroundColor=colors[num1+2];
				     div3.style.backgroundColor=colors[num1+3];
				    
			}else{
				 	 	var div=document.getElementById("mydiv"); 
						var div2=document.getElementById("mydiv2");
						var div3=document.getElementById("mydiv3");
						div.style.backgroundColor=colors[num1];
						div2.style.backgroundColor=colors[num1+1];
						div3.style.backgroundColor=colors[num1+2];
					num1++;
			}
			}
			function color1(){
					 var  xx1=prompt("小div",'');
					 var  xx2=prompt('中div','');
					 var  xx3=prompt('大div','');
					var div=document.getElementById("mydiv"); 
					var div2=document.getElementById("mydiv2");
			         var div3=document.getElementById("mydiv3");
			          div.style.backgroundColor=xx1;
				     div2.style.backgroundColor=xx2;
				     div3.style.backgroundColor=xx3;
			         
			};
			
			function dianzan(obj){
			var num=obj.getAttribute("num");
			if(num%2!==0){
			num++;
			
			//点赞
			obj.style.color="red";
			obj.setAttribute("num",num);
			document.getElementById("dianzan").innerHTML="点赞";
		}else{
			num++;
			//取消点赞

	    	obj.style.color="black";
		    obj.setAttribute("num",num);
		    document.getElementById("dianzan").innerHTML="取消点赞";
		
	}		
		};
		function changColor(){
				var trnum=document.getElementById("mytable").getElementsByTagName("tbody").item(0).getElementsByTagName("tr").length;
					for(var i=0;i<=trnum;i++){
					if((i+1)%2!=0){
			var tr=document.getElementById("mytable").getElementsByTagName("tbody").item(0).getElementsByTagName("tr").item(i);
			tr.style.color="red";
		}
		}
	};
     	 function denglu(){
		 var account =document.getElementById("account").value;	
		 var passwrod=document.getElementById("password").value;
		
		  var zhanghao=/^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/;
		  var str1=/^[\w]{6,12}$/;
			
		  if(zhanghao.test(account)){
		  	if(str1.test(passwrod)){
		  		if(account==15575938041,passwrod=="admin123"){
		  			var aa=confirm("您确定要跳转吗");
			if(aa){
				window.location="https://www.baidu.com/";
			}
		  		}else{
		  			alert("账号或密码不正确");
		  		}
		  		
		  	}else{
		  		document.getElementById("text").innerHTML="密码格式不正确";
		  	}
		  	
		  }else{
		  	document.getElementById("text").innerHTML="账号格式不正确";
		  };
		 };


		</script>
	</body>
</html>
